import { InjectionKey } from 'vue';
import { useStore as baseUseStore, createStore, Store } from 'vuex';

export interface State {
    username: string,
    // count: number,
};

export const key: InjectionKey<Store<State>> = Symbol();


export const store = createStore({
    state: {
        username: 'Zhang san',
    },
    getters: {
        getName: (state) => {
            return state.username
        }
    },
    mutations: {
        SET_USERNAME(state, username: string){
            state.username = username;
        }
    },
    actions: {},
})

//定义自己的组合式函数
export function useStore() {
    return baseUseStore(key)
}
